package presencial2014;
import java.util.ArrayList;
import java.util.Scanner;

public class I {

	@SuppressWarnings("resource")
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while (in.hasNext()) {
			ArrayList<Float> c = new ArrayList<Float>();
			for (int i = 0; i < 7; i++) {
				float f = in.nextFloat();
				// System.out.println(f);
				c.add(f);
			}
			// System.out.println(c);
			eliminarMinimo(c);
			// System.out.println(c);
			eliminarMinimo(c);
			// System.out.println(c);
			eliminarMaximo(c);
			// System.out.println(c);
			eliminarMaximo(c);
			// System.out.println(c);
			float suma = 0;
			for (float f : c) {
				suma += f;
			}
			System.out.println((long) (suma * 2));
		}

	}

	private static void eliminarMinimo(ArrayList<Float> c) {
		float min = c.get(0);
		for (float n : c) {
			if (n < min) {
				min = n;
			}
		}
		c.remove(min);
	}

	private static void eliminarMaximo(ArrayList<Float> c) {
		float max = c.get(0);
		for (float n : c) {
			if (n > max) {
				max = n;
			}
		}
		c.remove(max);
	}

}
